import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import qiankun from 'vite-plugin-qiankun'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    // 在开发模式下需要把react()关掉
    // react(),
    //@ts-ignore
    qiankun('sub-react', { useDevMode: true }),
  ],
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
      },
    },
  },
  resolve: {
    // 路径别名
    alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
  },
  server: {
    // 打开端口
    port: 7013,
    // 是否开启https服务
    https: false,
    // // 代理
    proxy: {
      '/api1': {
        target: 'http://localhost:7011/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api1/, ''),
      },
    },
  },
})
